<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        class Person {
            constructor(name) {
                this.name = name;
            };
            showname() {
                console.log('父类的方法');
            };
        };

        class Stu extends Person {
            constructor(name, skill) {
                super(name); // 相当于父级的构造函数
                this.skill = skill; // Stu本身的属性
            }
            showname() {
                super.showname(); //父级的方法执行

                // 做子级的事情
                console.log('子类的方法');
            };
            showskill() {
                return `我的技能是${this.skill}` // 自己身上加方法
            }
        };
        let stu1 = new Stu('小白', '逃学');
        console.log(stu1.name);
        console.log(stu1.skill);
        console.log(stu1.showskill());
        console.log(stu1.showname());
    </script>
</body>

</html>